﻿using Sirenix.OdinInspector;
using Sirenix.Utilities;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace PureOdinTools
{
    public class TagTool : GlobalConfig<TagTool>
    {
        public List<string> tags = new List<string>();
        [OnInspectorInit("OnInit")]
        private void OnInit()
        {
            tags.Clear();
            SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
            SerializedProperty it = tagManager.GetIterator();
            while (it.NextVisible(true))
            {
                if(it.name == "tags")
                {
                    Debug.Log("1231231");
                }
                if (it.name == "m_SortingLayers")
                {
                    var count = it.arraySize;
                    for (int i = 0; i < count; i++)
                    {
                        var dataPoint = it.GetArrayElementAtIndex(i);
                        while (dataPoint.NextVisible(true))
                        {
                            if (dataPoint.name == "name")
                            {
                                Debug.Log(dataPoint.stringValue);
                                tags.Add(dataPoint.stringValue);
                            }
                        }
                    }
                    return;
                }
            }
        }
    }
}